//
//  XFBaseTableViewController.swift
//  SinaBlog
//
//  Created by macs on 15/11/8.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

import UIKit


//App Key：2183042437
//App Secret：3ec2a75c3118a63c78547813e349de08
class BaseTableViewController: UITableViewController ,VisitViewDelegate{
    //判断用户是否登录
    var isLogin = AccessViewModel().userLogin
    /**
     loadView是特意提供为手写代码而设置的,当重写该方法时, story,xib 将失去效果
     系统会自动查看 view 是否为空,如果为空,就会调用该方法
     */
    
    var visitLoginView : XFVisitView?
    override func loadView() {
//        print(isLogin)
        isLogin ? super.loadView() : loadVisitView()
        
    }
    
    
    func loadVisitView() {
        
        visitLoginView = XFVisitView()
        visitLoginView?.visitViewDelegate = self
        view = visitLoginView
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitWillLogin")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitWillRegist")
        
    }
    func visitWillLogin() {
        //
       // print("\(__FUNCTION__)")
        let vc = OauthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    func visitWillRegist() {
        //
       // print("\(__FUNCTION__)")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
       
    }
    
    
}
